//! $Id: ContextCommit.h 27 2011-09-16 13:28:08Z skagget77 $
//!
//! @file    ContextCommit.h
//! @author  Johan Andersson <skagget77@gmail.com>
//! @date    Sat Oct 03 19:59 2009
//! @ingroup IoCpp

#if !defined(IOCPP_CONFIG_CONTEXTCOMMIT_H)
#define IOCPP_CONFIG_CONTEXTCOMMIT_H

#include "IoCpp/IContainer.h"

namespace IoCpp
{
   //!
   //! @author  Johan Andersson <skagget77@gmail.com>
   //! @date    Sat Oct 03 19:59 2009
   //! @ingroup IoCpp
   //!
   //! The ContextCommit class, a shared_ptr custom deleter that commits the
   //! managed configuration context to the container before deleting it.
   //!
   template<class T1>
   class ContextCommit
   {
   public :
      //!
      //! Commits the configuration context to the container. After the context
      //! has been commited it is deleted.
      //!
      //! @param context The configuration context.
      //!
      void operator()( T1* context ) const
      {
         context->Commit();
         delete context;
      }
   };
}

#endif   // IOCPP_CONFIG_CONTEXTCOMMIT_H
